# _author_=xiaowen
# _desc_=计算四个次大值

"""
算法思路，
1、三个值中计算最大值，最小值、中间值
2、假定第四个为次大值，违反假定条件
a：大于三个中最大值，
b：小于中值次大值为中值，
"""

import random

x = random.randint(-10**2,10**2)
y = random.randint(-10**2,10**2)
z = random.randint(-10**2,10**2)
k = random.randint(-10**2,10**2)

max_ = min_ = x

if y > max_:
    max_ = y
if y < min_:
    min_ = y

if z > max_:
    max_ = z
if z < min_:
    min_ = z

median = x+y+z-max_-min_
max_n2 = k

# 只做一件事算次大值
if k > max_:
    max_n2 = max_
elif k < median:
    max_n2 = median

print("x:{} y:{} z:{} k:{},次大值：{}".format(x,y,z,k,max_n2))